import { request } from './request'
// 获取用户创建的歌单
export function _getSongList (id) {
  return request({
    url: '/user/playlist',
    params: {
      uid: id
    }
  })
}

// 检测手机号是否已经注册
export function _phoneVerify (phone) {
  return request({
    url: 'cellphone/existence/check',
    params: {
      phone: phone
    }
  })
}
// 登录请求
export function _login (phone, password) {
  return request({
    url: '/login/cellphone',
    params: {
      phone: phone,
      password: password
    }
  })
}
// 获取验证码
export function _getcaptcha (phone) {
  return request({
    url: '/captcha/sent',
    params: {
      phone: phone
    }
  })
}
// 验证验证码
export function _checkCaptcha (phone, captcha) {
  return request({
    url: '/captcha/verify',
    params: {
      phone: phone,
      captcha: captcha
    }
  })
}
// 注册
export function _register (phone, password, captcha, nickname) {
  return request({
    url: '/register/cellphone',
    params: {
      phone: phone,
      password: password,
      captcha: captcha,
      nickname: nickname
    }
  })
}
// 邮箱登陆
export function _email (email, password) {
  return request({
    url: '/login',
    params: {
      email: email,
      password: password
    }
  })
}
// 获取用户信息
export function _getUserMessage (uid) {
  return request({
    url: '/user/detail',
    params: {
      uid: uid
    }
  })
}
// 提取用户重要信息
export class User {
  constructor (user) {
    this.level = user.level;
    // 关注
    this.follows = user.profile.follows;
    this.cCount = user.profile.cCount;
    // 动态
    this.accountStatus = user.profile.accountStatus;
    this.place = user.profile.city;
    this.creatTime = user.createTime;
    // 听歌数量
    this.listenSongs = user.listenSongs;
  }
}
// 获取用户播放记录
export function _getPlaylist (uid, type) {
  return request({
    url: 'user/record',
    params: {
      uid: uid,
      type: type
    }
  })
}
